/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CreditPaymentPanel.java
 *
 * Created on Feb 22, 2011, 12:18:29 PM
 */

package POSTApp;
import Payment.Payment;
import Payment.CreditPayment;

/**
 * GUI panel for processing credit payments.
 * @author Rebecca Bettencourt
 */
public class CreditPaymentPanel extends PaymentPanel {

    /** Creates new form CreditPaymentPanel */
    public CreditPaymentPanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ccLabel = new javax.swing.JLabel();
        ccNumber = new javax.swing.JTextField();

        ccLabel.setText("Credit Card Number:");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(ccLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ccNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(ccLabel)
                .add(ccNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ccLabel;
    private javax.swing.JTextField ccNumber;
    // End of variables declaration//GEN-END:variables

    public Payment getPayment(float total) {
        return new CreditPayment(total, Integer.parseInt(ccNumber.getText()));
    }

    public void clearPayment() {
        ccNumber.setText("");
    }
}
